# Makefile for ZIP file distribution of LocoBidder and LocoGateway
# usage:
# make zip

# this list should contain all files to include in the distributed ZIP
files =	LocoBidder.lua LocoBidder.xml LocoBidder.toc LocoGateway.pyw README.txt
files_gui = LocoBidder_GUI.lua LocoBidder_GUI.xml LocoBidder_GUI.toc
files_emblem = EmblemLootDisable.lua EmblemLootDisable.toc

zip: ${files} ${files_gui} ${files_emblem}
	# put files in a subdir so that the directory information is saved in the ZIP
	mkdir LocoBidder
	@for file in ${files};\
	do\
		cp "$$file" ./LocoBidder;\
	done
	mkdir LocoBidder_GUI
	@for file in ${files_gui};\
	do\
		cp "$$file" ./LocoBidder_GUI;\
	done
	mkdir EmblemLootDisable
	@for file in ${files_emblem};\
	do\
		cp "$$file" ./EmblemLootDisable;\
	done
	# zip it!
	zip -r LocoBidder-TEMP.zip ./LocoBidder/* ./LocoBidder_GUI/*
	zip -r EmblemLootDisable-TEMP.zip ./EmblemLootDisable/*
	# clean up
	rm ./LocoBidder/*
	rm ./LocoBidder_GUI/*
	rm ./EmblemLootDisable/*

	rmdir ./LocoBidder
	rmdir ./LocoBidder_GUI
	rmdir ./EmblemLootDisable
	# rename the new ZIP to the filename format LocoBidder-VERSION-rREVISION.zip
    # version is the 3rd column of the first line of ./LocoBidder.lua
    # revision is the 4th line of ./.svn/entries
	mv LocoBidder-TEMP.zip LocoBidder-`head -1 LocoBidder.lua | awk '{ print $$3 }'`-r`head -4 ./.svn/entries | tail -1`.zip
	mv EmblemLootDisable-TEMP.zip EmblemLootDisable-`head -1 EmblemLootDisable.lua | awk '{ print $$3 }'`-r`head -4 ./.svn/entries | tail -1`.zip
